package basic_practice_1022;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
 * @author MemoryC
 * */

public class Main {

	static List<Integer>times;
	static int MaxN=0;
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
	
		
		while(scanner.hasNext()) {
			int n=scanner.nextInt();
			if(n==0) {
				break;
			}
			if(n<2) {
				System.out.println(0);
				continue;
			}
			if(n<4) {
				System.out.println(1);
				continue;
			}
			if(n<=9) {
				System.out.println(2);
				continue;
			}
			int cnt=2;
			while(n>9) {
				int a=n/3;
				int b=(n-a)/2;
				int c=n-a-b;

				cnt++;
				n=c;
			}
			System.out.println(cnt);
		}
		scanner.close();
    }
	
}
class Main2 {

	static List<Integer>times;
	static int MaxN=0;
	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
		
		times=new ArrayList<>();
		times.add(0);
		times.add(0);
		times.add(1);
		times.add(1);
		times.add(2);
		times.add(2);
		MaxN=5;
		
		for(int n=6;n<1000;n++) {
			int a=n/3;
			int b=(n-a)/2;
			int c=n-a-b;

			int tc=times.get(c)+1;
			times.add(tc);
			MaxN++;
		}
		
		while(scanner.hasNext()) {
			int n=scanner.nextInt();
			if(n==0) {
				break;
			}
			if(n<=MaxN) {
				System.out.println(times.get(n));
			}else {
				System.out.println(getTime(n));
			}
			
		}
		scanner.close();
    }
	
	static int getTime(int n) {
		if(n<=MaxN) {
			return times.get(n);
		}else {
			int a=n/3;
			int b=(n-a)/2;
			int c=n-a-b;

			int tc=getTime(c)+1;
			
			return tc;
			
		}
	}
}